﻿using AutoMapper;
using BW.MesProject.BasicData.Domain.基础;
using BW.MesProject.BasicData.Infrastructure;
using BW.MesProject.Public.ErrorCode;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BW.MesProject.BasicData.Host.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class WorkShopController : ControllerBase
    {
        private readonly IWorkShopServices workShopServices;

        public WorkShopController(IWorkShopServices workShopServices)
        {
            this.workShopServices = workShopServices;
        }
        /// <summary>
        /// 车间添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddWorkShop(Workshopmanagementmodel model)
        {
          return workShopServices.AddWorkShop(model);
        }
        /// <summary>
        /// 删除车间
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> DeleteWorkShop(long id)
        {
          return workShopServices.DeleteWorkShop(id);
        }
        /// <summary>
        /// 获取车间
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<List<Workshopmanagementmodel>> GetWorkShop(string? shopcode, string? shopname, int pageindex, int pagesize)
        {
            return workShopServices.GetWorkShop(shopcode,shopname, pageindex,  pagesize);
        }
        /// <summary>
        /// 修改车间
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateWorkShop(Workshopmanagementmodel model)
        {
            return workShopServices.UpdateWorkShop(model);
        }
        /// <summary>
        /// 根据id获取车间信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<Workshopmanagementmodel>> GetShop(long id)
        {

          return workShopServices.GetShop(id);
        }
        /// <summary>
        /// 获取所有车间信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<Workshopmanagementmodel>> GetAllShop()
        {
          return workShopServices.GetAllShop();
        }

    }
}
